/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.gerenciadoc.dao;

import br.com.gerenciadoc.modelo.Documento;
import java.util.Iterator;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Order;

/**
 *
 * @author pedrogazzola
 */
public class DAODocumento extends DAOGenerica {

    public DAODocumento() {
    }
    
    public List carregarTudoOrdenado(Class clas, String ordem) {
        Session session = hibernateConfiguracao.openSession();
        Criteria criteria = session.createCriteria(clas);
        criteria.addOrder(Order.asc(ordem));
        List lista = criteria.list();
        Iterator i = lista.iterator();
        while(i.hasNext()){
            Documento doc = (Documento) i.next();
            doc.getUsuario().getNome();
        }
        session.close();
        return lista;
    }
}
